package com.itheima.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ZhangyiA
 * @describe:
 * @date 2021/06/23
 */

public class DateConverter implements Converter< String, Date> {

    public Date convert(String dateSter) {
        // 将日期的字符串转换成真正的时间对象返回
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = format.parse(dateSter);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}
